<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ajax--post 请求</title>
    <script src="libs/jquery1.js"></script>
</head>

<body>
    <form action="login" method="post" enctype="application/x-www-form-urlencode">
        <input type="text" name="username" placeholder="请输入姓名"><br>
        <input type="password" name="password" placeholder="请输入密码"><br>
        <button type="submit">登录</button>
    </form>
</body>
<script>
    // ajax: Asynchronous javascript and xml
    // 异步的js 与xml
    // 在不重载页面的条件下更新页面数据

    $('form').submit(function (ev) {
        // 阻止默认事件
        ev.preventDefault();
        console.log('已经组织');
        // 获取表单数据，自动将其转换成字符串序列化对
        var data = $(this).serialize();
        $.post(
            'index.html',             //请求路径
            data,         //请求数据 
            function (resData) {

            }
        )
    })

</script>

</html>